package io.kiki.stack.http.feign.form.multipart;

import feign.codec.EncodeException;

/**
 * A writer interface.
 *
 * @author Artem Labazin
 */
public interface Writer {

    /**
     * Processing form data to request body.
     *
     * @param output   output writer.
     * @param boundary data boundary.
     * @param key      name for piece of data.
     * @param value    piece of data.
     * @throws EncodeException in case of any encode exception
     */
    void write(Output output, String boundary, String key, Object value) throws EncodeException;

    /**
     * Answers on question - "could this writer properly write the value".
     *
     * @param value object to write.
     * @return {@code true} - if could write this object, otherwise {@code true}
     */
    boolean isApplicable(Object value);
}
